﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        //根据位置返回字符
        //cgarAt(index) 根据索引返回字符
        let str = `abcef`;
        console.log(str.charAt(1));

        //charCodeAt(index)  返回相应索引号的字符 ASCII 值 目的： 判断用户按下了那个键
        console.log(str.charCodeAt(0));

        // ASCII码值转换为对应字符
        let result = String.fromCharCode(65);
        console.log(result);

        let arr = [];
        for (let i = 65; i < 91; i++) {
            let temp = String.fromCharCode(i);
            arr.push(temp);
        }
        console.log(arr);

        // str[index] H5 新增的
        console.log(str[0]);
    </script>
</body>
</html>